package com.tanhua.server.service;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.dubbo.server.api.RecommedApi;
import com.tanhua.dubbo.server.pojo.RecommendUser;
import com.tanhua.server.vo.TodayBest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class RecommedApiService {
    @Reference(version = "1.0.0")
    private RecommedApi recommedApi;

    public TodayBest getTodayBest(Long userId) {
        RecommendUser recommendUser = recommedApi.getRecommendUser(userId);
        if (ObjectUtil.isEmpty(recommendUser)) {
            return null;
        }
        TodayBest todayBest = new TodayBest();
        todayBest.setId(recommendUser.getUserId());
        double floor = Math.floor(recommendUser.getScore());
        todayBest.setFateValue(Double.valueOf(Double.valueOf(floor)).longValue());
        return todayBest;
    }


    public List<RecommendUser> getAllTodayBest(Integer page, Integer pageSize, Long userId) {
        return recommedApi.getAllTodayBest(page,pageSize,userId);
    }
}
